package com.sky.minioall.pojo;

import io.minio.MinioClient;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

@Data
@AllArgsConstructor
@NoArgsConstructor
@Component
@ConfigurationProperties("sky.minio")
public class MinionUploader {
        private String endpoint;
        private String accessKeyId;
        private String accessKeySecret;
        private String bucketName;


        @Bean
        @ConditionalOnMissingBean
        public MinioClient minioClient() {
                //构建MinioClient对象
                return MinioClient.builder()
                        .endpoint(endpoint)
                        .credentials(accessKeyId, accessKeySecret)
                        .build();
        }
}
